<script type="text/javascript" language="javascript">
    (function($) {
        /*whatever jQuery stuff*/
        $(function(){
            jQuery.validator.addMethod("EmailValid", function(value, element, param) {
                var returnVal = true;
				$.ajax({
					url:'<?php echo get_url(2);?>/ajax_email_valid',
					type:'post',
					data:({
						email : value,
						old_email : '<?php echo $dataResult->email;?>'
					}),
					async:false,					
					success: function(data){
						if(data==1){
							returnVal = false;
						}
					}
				});
				return returnVal;
           	}, jQuery.validator.messages.EmailValid);			
						
            $("#Form").validate({
                rules: {
                    repassword: {
						equalTo: "#newpassword"
					},
                    email: {
						required:true,
						EmailValid:true
					}
                },
                showErrors: function(errorMap, errorList){
                    var messages='';
                    for (var i = 0; i < errorList.length; i++) {					
                        messages += '- '+errorList[i].message+'\n';
                    }
                    if(messages) alert("<?php echo lang('requirement');?>: \n"+"¯¯¯¯¯¯¯¯¯¯ \n"+ messages);
                    //this.defaultShowErrors();
                } ,
                submitHandler: function(e){
					$('.ajax-loading',e).css('visibility','visible');
					form.submit();
                },
                onfocusout: false,
                onkeyup: false,						
                messages: {
					repassword: {
						equalTo : "<?php echo lang('password_not_match');?>"
					},
                    email: {
						required : "<?php echo lang('email');?>",
						EmailValid : "<?php echo lang('email_not_valid');?>"
					},					
                }
            });
			
			$('input#birthdate').simpleDatepicker({ startdate: 1950, enddate: new Date() });			
        });
    })(jQuery);
</script>
<div class="wrap">
 	<div id="icon-index" class="icon32"><br /></div><h2><?php echo ucwords(str_replace('_',' ',$this->uri->segment(1)));?> &raquo; <?php echo ucwords(str_replace('_',' ',$this->uri->segment(2)));?></h2>
</div>
<div id="wpbody-content">
    <div class="metabox-holder" id="dashboard-widgets">
            <div class="inside">			
				<form id="Form" method="post" action="" name="Form">
					<table border="0" cellspacing="0" cellpadding="0" class="form-table">
						<tbody>					
						<tr>
							<th scope="row"><?php echo lang('username');?></th>
							<td><input type="text" name="username" id="username" class="medium-text" value="<?php echo htmlspecialchars($dataResult->username, ENT_QUOTES, 'UTF-8');?>" readonly="readonly"/></td>
						</tr>
						<tr>
							<th scope="row"><?php echo lang('newpassword');?></th>
							<td><input type="password" name="newpassword" id="newpassword" class="medium-text" autocomplete="off"/></td>
						</tr>
						<tr>
							<th scope="row"><?php echo lang('repassword');?></th>
							<td><input type="password" name="repassword" id="repassword" class="medium-text" autocomplete="off"/></td>
						</tr>						
						<tr>
							<th scope="row"><?php echo lang('email');?></th>
							<td><input type="text" name="email" id="email" class="regular-text" value="<?php echo $dataResult->email;?>"/></td>
						</tr>
						<tr>
							<th scope="row"><?php echo lang('firstname');?></th>
							<td><input type="text" name="firstname" id="firstname" class="regular-text" value="<?php echo htmlspecialchars($dataResult->firstname, ENT_QUOTES, 'UTF-8');?>"/></td>
						</tr>
						<tr>
							<th scope="row"><?php echo lang('surname');?></th>
							<td><input type="text" name="surname" id="surname" class="regular-text" value="<?php echo htmlspecialchars($dataResult->surname, ENT_QUOTES, 'UTF-8');?>"/></td>
						</tr>
						<tr>
							<th scope="row"><?php echo lang('nickname');?></th>
							<td><input type="text" name="nickname" id="nickname" class="regular-text" value="<?php echo htmlspecialchars($dataResult->nickname, ENT_QUOTES, 'UTF-8');?>"/></td>
						</tr>
						<tr>
							<th scope="row"><?php echo lang('phone');?></th>
							<td><input type="text" name="phone" id="phone" class="regular-text" value="<?php echo htmlspecialchars($dataResult->phone, ENT_QUOTES, 'UTF-8');?>"/></td>
						</tr>
						<tr>
							<th scope="row">&nbsp;</th>
							<td><p class="submit"><input type="submit" value="<?php echo lang('button_edit');?>" class="button-primary" />&nbsp;<img alt="" class="ajax-loading" src="<?php echo css_asset_url('images/wpspin_light.gif'); ?>" /></p></td>
						</tr>								
						</tbody>
					</table>
					<div class="tablenav bottom"></div>
				</form>
            </div><!-- wpbody inside -->
    </div><!-- wpcontent -->
</div><!-- wpbody-content -->